{include file="public/header" /}
<style>
    .layui-form-label{width: 180px;margin-left: -55px}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑属性</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md6">
                            <label class="layui-form-label">属性名称_英文：</label>
                            <div class="layui-input-block">
                                <input type="text" name="name_en" value="{$data.attr_name_en}" lay-verify="required" placeholder="属性名称_英文" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md6">
                            <label class="layui-form-label">属性名称_西班牙：</label>
                            <div class="layui-input-block">
                                <input type="text" name="name_es"  value="{$data.attr_name_es}"lay-verify="required" placeholder="属性名称_西班牙" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md6">
                            <label class="layui-form-label">属性名称_葡萄牙：</label>
                            <div class="layui-input-block">
                                <input type="text" name="name_tp"  value="{$data.attr_name_tp}"lay-verify="required" placeholder="属性名称_葡萄牙" class="layui-input">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">状态：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="attr_status" value="1" class="layui-input" title="上架" {$data.attr_status == 1 ? 'checked' : ''} />
                                <input type="radio" name="attr_status" value="2" class="layui-input" title="下架" {$data.attr_status == 2 ? 'checked' : ''} />
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md6">
                            <label class="layui-form-label">排序：</label>
                            <div class="layui-input-block">
                                <input type="text" name="attr_sort" value="{$data.attr_sort}" lay-verify="required" placeholder="排序，数值越大越靠前" class="layui-input" oninput="value=value.replace(/[0][^\d]/g,'')">
                            </div>
                        </div>

                        <input type="hidden" value="{$data.attr_id}" name="attr_id">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}

<script>
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;

        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('attrEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        layer.msg(res.msg,{icon:1,time:1500,shade:0.1},function(index){
                            wk.layer_close();
                        });
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>
</body>
</html>
